//    Copyright (C) Kherty.  All rights reserved.
using System.Windows;
using System.Windows.Controls;

namespace OpenLS.Drawing.UI
{
    partial class GradientResources
    {
        public GradientResources()
        {
            InitializeComponent();
        }

        private void OnAdd(object sender, RoutedEventArgs e)
        {
            var g = (GradientFillProperties) ((FrameworkElement) sender).DataContext;
            g.GradientStops.Add(new GradientStop());
            e.Handled = true;
        }

        private void OnRemove(object sender, RoutedEventArgs e)
        {
            var b = (Button) sender;
            var lb = (ListBox) b.Tag;
            if (lb.SelectedIndex >= 0)
            {
                var g = (GradientFillProperties) ((FrameworkElement) sender).DataContext;
                g.GradientStops.RemoveAt(lb.SelectedIndex);
            }
            e.Handled = true;
        }
    }
}
